package cn.iocoder.yudao.module.def.controller.admin.defcommon;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.def.dal.dataobject.project.ProjectDO;
import cn.iocoder.yudao.module.def.service.common.DefCommonService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.security.PermitAll;

import java.util.List;
import java.util.Map;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 地图的四个接口")
@RestController
@RequestMapping("/projectMap")
@Validated
@AllArgsConstructor
public class CommonController {

    private final DefCommonService commonService;

    @PostMapping("/yearList")
    @Operation(summary = "获取竣工年份列表")
    @PermitAll
    public List<Map<String, Object>> getProject() {
        return commonService.getCompletedYearList();
    }

    @PostMapping("/projectCate")
    @Operation(summary = "获取项目分类")
    @PermitAll
    public List<Map<String, Object>> getProjectCate() {
        return commonService.getProjectCate();
    }

    @PostMapping("/projectCate1")
    @Operation(summary = "获取项目分类1")
    @PermitAll
    public CommonResult<List<Map<String, Object>>> getProjectCate1() {
        return success(commonService.getProjectCate());
    }

    @PostMapping("/index")
    @Operation(summary = "根据搜索参数获取聚合点数据")
    @PermitAll
    public List<Map<String, Object>> getIndex(String project_cate,
                                              String finish_date,
                                              String keyword,
                                              String sydw,
                                              String jsqy,
                                              String jsdw) {
        return commonService.selectProjectsIndex(project_cate, finish_date,keyword,sydw,jsqy,jsdw);
    }

    @GetMapping("/info")
    @Operation(summary = "根据点位id获取详情信息")
    @PermitAll
    public Map<String, Object> getInfo(@RequestParam("id") Integer id){
        return commonService.getInfo(id);
    }


    @GetMapping("/area")
    @Operation(summary = "获取区域列表")
    @PermitAll
    public List<Map<String, Object>> getArea(){
        return commonService.getArea();
    }

    @GetMapping("/useCompany")
    @Operation(summary = "获取使用单位列表")
    @PermitAll
    public List<Map<String, Object>> getUseCompany(){
        return commonService.getUseCompany();
    }

    @GetMapping("/buildCompany")
    @Operation(summary = "获取建设单位列表")
    @PermitAll
    public List<Map<String, Object>> getBuildCompany(){
        return commonService.getBuildCompany();
    }
}

